library(dplyr)
library(magrittr)
library(tidyr)
library(ggplot2)

dat <- rio::import("data/Demo_book_country_4_1600.dta")

p <- dat %>%
  filter(year >= 1600) %>%
  ggplot(aes(x = eur_pct_est_smooth)) +
  geom_histogram(aes(y = stat(count)/sum(stat(count))),
                 bins = 20, color = "black", fill = "white") +
  labs(y = "Frequency", x = "Share of Europeans (%)") +
  theme(panel.grid.minor = element_blank(),
        panel.background = element_blank(),
        panel.grid.major = element_blank(),
        panel.border = element_blank(),
        axis.line = element_line(color = "black"),
        plot.margin = margin(1, 1, 1, 0.25, "cm"))

## ggsave(p, file = "figure_9_3.png",
##        width = 11, height = 8.5)

ggsave(p, file = "output/figure_9_2.tiff",
       width = 11, height = 8.5, dpi = 300)
